﻿<UserControl x:Class="BillsManager.Views.DataTemplates.BackupDataTemplate"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:ViewModels="clr-namespace:BillsManager.ViewModels;assembly=BillsManager.ViewModels"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Loc="clr-namespace:BillsManager.Localization;assembly=BillsManager.Localization"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             d:DataContext="{d:DesignInstance Type=ViewModels:BackupViewModel,
                                              IsDesignTimeCreatable=True}"
             mc:Ignorable="d">

    <UserControl.Resources>
        <!--<ResourceDictionary Source="/BillsManager.Views;component/Dictionaries/Styles.xaml" />-->
        <ResourceDictionary Source="/BillsManager.Views;component/Themes/Themes.xaml" />
    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="{StaticResource View.MarginSize}" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="{StaticResource View.MarginSize}" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <TextBlock Grid.Column="1" Text="{Binding CreationTime, StringFormat=\{0:F\}, Mode=OneTime}" />

        <TextBlock Grid.Row="2" Grid.Column="1">
            <Run Text="{Loc:Translate Suppliers}" />
            <Run Text="{Binding SuppliersCount, Mode=OneTime}" />
        </TextBlock>

        <TextBlock Grid.Row="4" Grid.Column="1">
            <Run Text="{Loc:Translate Bills}" />
            <Run Text="{Binding BillsCount, Mode=OneTime}" />
        </TextBlock>

        <TextBlock Grid.Row="6"
                   Grid.Column="1"
                   Visibility="{Binding HasNoRollbacks,
                                        Converter={StaticResource BooleanToVisibilityConverter}}">
            <Run Text="{Binding TimesUsedForRollback, Mode=OneTime}" />
            <Run Text=" rollbacks" />
        </TextBlock>

        <Expander Grid.Row="6"
                  Grid.Column="1"
                  Background="{x:Null}"
                  BorderBrush="{x:Null}"
                  BorderThickness="0"
                  Focusable="False"
                  Foreground="{Binding Foreground,
                                       RelativeSource={RelativeSource FindAncestor,
                                                                      AncestorType={x:Type UserControl}}}"
                  Visibility="{Binding HasRollbacks,
                                       Converter={StaticResource BooleanToVisibilityConverter}}">
            <Expander.Header>
                <TextBlock Grid.Column="1">
                    <Run Text="{Binding Path=TimesUsedForRollback, Mode=OneTime}" />
                    <Run Text=" rollbacks" />
                </TextBlock>
            </Expander.Header>

            <ItemsControl ItemsSource="{Binding RollbackDates}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Margin="28 8 0 0" Text="{Binding Mode=OneWay, StringFormat=\{0:F\}}" />
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Expander>

    </Grid>
</UserControl>